package com.ssfeng.proxy2;

import java.lang.reflect.Method;

/**
 * Created by liyuhang on 2020-09-10.
 */
public class MyProxyInvocationHandler<T> implements MyInvocationHandler {


    private T target;



    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        before();
        Object result = method.invoke(target, args);
        after();

        return result;
    }


    public MyProxyInvocationHandler(T target) {
        this.target = target;
    }

    public void before() {
        System.out.println("我的名字之前...");
    }

    public void after() {
        System.out.println("我的名字之后...");
    }
}
